home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 5 / The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO / amiga / tempdemo.lha / ProgrammersInfo / DSKEL-WHOsd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-22  |  13.4 KB  |  461 lines

  1. /*
  2.     ╔═══════╦═════════════════════════════╦═══════════════════╦═══════════════╗
  3.     ║ LoGoN ║ HanDLe / LoCATioN           ║ ACTiViTY          ║  FiLE Status  ║
  4. ╔═══║═══════║═════════════════════════════║═══════════════════║═══════════════╣
  5. ║ 1 ║ 19:44 ║ The Skeleton                ║ DownLoading       ║  12345678.dms ║
  6. ╚═══╣  2400 ║ Crystal And Indepdanant     ║ CPS Rate: 1623    ║ 4588383 Bytes ║
  7. ╔═══║═══════║═════════════════════════════║═══════════════════║═══════════════╣
  8. ║ 2 ║ 19:33 ║ The Skeleton                ║ DownLoading       ║  12345678.dms ║
  9. ╚═══╣ 19200 ║ Crystal / Indepdanant       ║ CPS Rate: 1222    ║ 4588383 Bytes ║
  10. ╔═══║═══════║═════════════════════════════║═══════════════════║═══════════════╣
  11. ║ 3 ║ 11:33 ║ The Skeleton                ║ DownLoading       ║  12345678.dms ║
  12. ╚═══╣ 14400 ║ Crystal / Indepdanant       ║ CPS Rate: 1993    ║ 4588383 Bytes ║
  13. ╔═══║═══════║═════════════════════════════║═══════════════════║═══════════════╣
  14. ║ 4 ║   :   ║ [ Hiding from display ]     ║ Logging On        ║ ------------- ║
  15. ╚═══╣       ║                             ║                   ║               ║
  16. ╔═══║═══════║═════════════════════════════║═══════════════════║═══════════════╣
  17. ║15 ║   :   ║                             ║ Waiting for call  ║               ║
  18. ╚═══╣       ║                             ║                   ║               ║
  19.     ║═══════╩═════════════════════════════╩═══════════════════╩═══════════════║
  20.     ║══════════════════╦══════════════════╦═════════════════╦═════════════════╣
  21.     ║ Active Lines: 11 ║ Users Online: 11 ║ Free Lines: 22  ║                 ║
  22.     ╚══════════════════╩══════════════════╩═════════════════╩═════════════════╝
  23.  
  24.     .-------.-----------------------------.-------------------.---------------.
  25.     | LoGoN | HanDLe / LoCATioN           | ACTiViTY          |  FiLE Status  |
  26. .---|-------|-----------------------------|-------------------|---------------|
  27. | 1 | 19:44 | The Skeleton                | DownLoading       |  12345678.dms |
  28. `---|  2400 | Crystal And Indepdanant     | CPS Rate: 1623    | 4588383 Bytes |
  29. .---|-------|-----------------------------|-------------------|---------------|
  30. | 2 | 19:33 | The Skeleton                | DownLoading       |  12345678.dms |
  31. `---| 19200 | Crystal / Indepdanant       | CPS Rate: 1222    | 4588383 Bytes |
  32. .---|-------|-----------------------------|-------------------|---------------|
  33. | 3 | 11:33 | The Skeleton                | DownLoading       |  12345678.dms |
  34. `---| 14400 | Crystal / Indepdanant       | CPS Rate: 1993    | 4588383 Bytes |
  35. .---|-------|-----------------------------|-------------------|---------------|
  36. | 4 |   :   | [ Hiding from display ]     | Logging On        | ------------- |
  37. `---|       |                             |                   |               |
  38. .---|-------|-----------------------------|-------------------|---------------|
  39. |15 |   :   |                             | Waiting for call  |               |
  40. `---|       |                             |                   |               |
  41.     |-------^-----------------------------^-------------------^---------------|
  42.     |------------------.------------------.-----------------.-----------------|
  43.     | Active Lines: 11 | Users Online: 11 | Free Lines: 22  |                 |
  44.     `------------------^------------------^-----------------^-----------------'
  45.  
  46. */
  47. //**********************
  48. //*****  Includes  *****
  49. //**********************
  50.  
  51. #include <proto/all.h>
  52. #include <stdio.h>
  53. #include <exec/memory.h>
  54.  
  55. #include <string.h>
  56. #include <tempest/headers.h>
  57. #include <tempest/defines.h>
  58.  
  59. //********************************
  60. //*****  Structures/Defines  *****
  61. //********************************
  62.  
  63.  
  64. struct MyMessage
  65.  {
  66.   struct Message Msg;
  67.   struct User User;
  68.   char text[255],
  69.        text1[255];
  70.   int car,Value,Data;
  71.   long LongValue;
  72.   int  IntValue;
  73.  };
  74.  
  75. struct User User;
  76. struct MsgPort *MyPort = NULL;
  77. struct MyMessage *msg;
  78. struct Down_Load Down_Load;
  79. struct DownLoad_Status DownLoad_Status;
  80.  
  81. struct node_info nody;
  82.  
  83. void CloseStuff();
  84. void pl(char outstring[]);
  85. void GetStr(char s[],int opt);
  86. int hotkey(char character[]);
  87. void RIPIT(char *,char *);
  88. int DOORIO();
  89. int KEY(void);
  90. int Loadnody(int node);
  91.  
  92. //******************************
  93. //*****  Global Variables  *****
  94. //******************************
  95.  
  96. int  EXIT_FLAG, DOOR_DATA, DOOR_CAR, DOOR_VALUE, DOOR_VALUE1 = 0,
  97.      Result,Error,first = 0;
  98. char MyName[255],st[100],DOOR_MSG[255],DOOR_MSG1[255];
  99.  
  100. //******************
  101. //*****  Main  *****
  102. //******************
  103.  
  104. void main(int argc,char *argv[])
  105. {
  106.  struct FileInfoBlock *FBlock;
  107.  struct FileLock *FLock;
  108.  char string[255],string2[255];
  109.  char Handle[40],Location[40],Activity[30],Time[15],Filename[15],Filesize[15];
  110.  int  file,Position,stat,count=0,NODES,NODE,line;
  111.  int online=0;
  112.  register int i;
  113.  if(!DoorStart(argv[1])) { PutStr("[os2] Tempest Door\n"); exit(0); }
  114.  
  115.  if(!User.NFlags1 & NF1_ViewNodeLists) CloseStuff();
  116.  
  117. //********************************
  118. //*****  Load Internal.Data  *****
  119. //********************************
  120.  
  121.  NODE = atoi(argv[1]);
  122.  stat=Loadnody(NODE);
  123.  if(stat==0)
  124.   {
  125.    pl("NodeInfo File Not Found!\r\n");
  126.    CloseStuff();
  127.   }
  128.  NODES = nody.SystemDataInfo->NumberOfLines + 1;
  129.  line=0; // Line Counter
  130.  
  131. //***************************************
  132. //*****  Beginning oF Massive Loop  *****
  133. //***************************************
  134.  
  135.  pl("\f    ╔═══════╦═════════════════════════════╦═══════════════════╦═══════════════╗\r\n");
  136.  pl("    ║ LoGoN ║ HanDLe / LoCATioN           ║ ACTiViTY          ║  FiLE STATuS  ║\r\n");
  137.  
  138.  i=1;
  139.  do
  140.   {
  141.    if(CTRLC())
  142.     {
  143.      pl("Aborting Who Display!\r\n");
  144.      CloseStuff();
  145.     }
  146.    stat=Loadnody(i);
  147.    if(stat==0) setmem(&nody,sizeof(struct node_info),NULL);
  148.  
  149.    strcpy(Filename," ");
  150.    strcpy(Filesize," ");
  151.  
  152.    //***********************
  153.    //*****  Uploading  *****
  154.    //***********************
  155.    if(*nody.AN== 58) // Only If they are uploading!
  156.     {
  157.      sprintf(string,"%s",nody.NodeDataInfo->TempULWorkPath);
  158.      if((FLock =(struct FileLock *)Lock(string,ACCESS_READ))==NULL) CloseStuff();
  159.      if((FBlock=(struct FileInfoBlock *)AllocMem((long)sizeof(struct FileInfoBlock),MEMF_CHIP)) == NULL)
  160.       {
  161.        UnLock((BPTR)FLock);
  162.        CloseStuff();
  163.       }
  164.      Examine((BPTR)FLock,FBlock);
  165.      while ((ExNext((BPTR)FLock,FBlock))!=0)
  166.       {
  167.        if((FBlock->fib_DirEntryType) <0)
  168.         {
  169.          strcpy(Filename,FBlock->fib_FileName);
  170.          sprintf(Filesize,"%ld",FBlock->fib_Size);
  171.          break;
  172.         }
  173.       }
  174.      UnLock((BPTR)FLock);
  175.      FreeMem(FBlock,sizeof(struct FileInfoBlock));
  176.     }
  177.  
  178.    //********************************
  179.    //*****  Downloading Checks  *****
  180.    //********************************
  181.  
  182.    if(*nody.AN==18) // Only If they are Downloading!
  183.     {
  184.      sprintf(string, "NODE:Download_File_List_Node#%d",i);
  185.      sprintf(string2,"NODE:Download_File_Status_Node#%d",i);
  186.      file=Open(string2,MODE_OLDFILE);
  187.      if(file==0)
  188.       {
  189.        file=Open(string,MODE_OLDFILE);   // Single Downloading
  190.        if(file!=0) Read(file,(char *)&Down_Load, sizeof(struct Down_Load));
  191.       }
  192.      else
  193.       {
  194.        do
  195.         {
  196.          count++;
  197.          stat=Read(file,(char *)&DownLoad_Status, sizeof(struct DownLoad_Status));
  198.         }
  199.        while(stat > 0);
  200.        Close(file);
  201.        file=Open(string,MODE_OLDFILE);
  202.        count--;
  203.        Position=sizeof(struct Down_Load) * count;
  204.        Seek(file,Position,OFFSET_BEGINNING);
  205.        Read(file,(char *)&Down_Load, sizeof(struct Down_Load));
  206.       }
  207.      Close(file);
  208.      strcpy(string,Down_Load.File);
  209.      RIPIT(string,string2);
  210.      strcpy(Filename,string2);
  211.      sprintf(Filesize,"%ld",Down_Load.Bytes);
  212.      count=0;
  213.     }
  214.  
  215.    //**************************
  216.    //*****  Final Output  *****
  217.    //**************************
  218.  
  219.    strcpy(Handle,nody.UserInfo->Name);
  220.    if((*nody.hide==1)&&(User.Security!=255)&&(User.Name[0]!=NULL))
  221.     {
  222.      if(nody.UserInfo->Slot_Number==1) Handle[0]=NULL;
  223.      else strcpy(Handle,"[ Hiding From Display ]");
  224.      strcpy(Location," ");
  225.      strcpy(Filename," ");
  226.     }
  227.    if(Handle[0]!=NULL)
  228.     {
  229.      if((i!=(NODES-1))) online++;
  230.      sprintf(string,"%s",ctime(&nody.UserInfo->Time_Last_Connect));
  231.      strmid(string,Time,12,5);
  232.      strcpy(Location,nody.UserInfo->City);
  233.      strcpy(Activity,nody.activity);
  234.      line+=3;
  235.      pl("╔═══║═══════║═════════════════════════════║═══════════════════║═══════════════╣\r\n");
  236.      if(nody.NodeDataInfo->LocalMode==0) sprintf(string2,"%2d",i);
  237.      else                                strcpy(string2," L");
  238.  
  239.      sprintf(string,"%2s ║ %5s ║ %-27.27s ║ %-18.18s║  %-12.12s ║\r\n",
  240.                     string2,Time,Handle,Activity,Filename);
  241.      pl(string);
  242.      sprintf(string,"╚═══╣ %5.5d ║ %-27.27s ║ ",*nody.baudrate,Location);
  243.      pl(string);
  244.      if((*nody.AN==58)||(*nody.AN==18))
  245.       {
  246.        sprintf(string,"CPS Rate: %-4.4ld    ║ %7.7s Bytes ║\r\n",*nody.cps,Filesize);
  247.       }
  248.      else sprintf(string,"                  ║               ║\r\n");
  249.      pl(string);
  250.      if( ((line+3)>User.Length)&&((i+1)<NODES))
  251.       {
  252.        pl("    ║═══════║═════════════════════════════║═══════════════════║═══════════════║\r\n");
  253.        KEY();
  254.        line=0;
  255.       }
  256.     }
  257.    i++;
  258.   }
  259.  while(i<NODES);
  260.  
  261.  pl("    ║═══════╩═════════════════════════════╩═══════════════════╩═══════════════║\r\n");
  262.  pl("    ║══════════════════╦══════════════════╦═════════════════╦═════════════════╣\r\n");
  263.  sprintf(string,"    ║ Active Lines%2d ║ Users Online%2d ║ Free Lines%2d  ║                 ║\r\n",(NODES-2),online,(NODES-2-online));
  264.  pl(string);
  265.  pl("    ╚══════════════════╩══════════════════╩═════════════════╩═════════════════╝\r\n");
  266.  CloseStuff();
  267. }
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275. //************************
  276. //*****  Load Nody  ******
  277. //************************
  278.  
  279. int Loadnody(int node)
  280. {
  281.  char string[50];
  282.  register int y;
  283.  int file;
  284.  sprintf(string,"Node:NodeInfo_%d",node);
  285.  for(y=1;y<3;y++)
  286.   {
  287.    file=Open(string,MODE_OLDFILE);
  288.    if(file!=0)
  289.     {
  290.      Read(file,(char *)&nody,sizeof(struct node_info));
  291.      Close(file);
  292.      return(1);
  293.     }
  294.   }
  295.  return(0);
  296. }
  297.  
  298. //*******************
  299. //*****  Ripit  *****
  300. //*******************
  301.  
  302. void RIPIT(char path[100],char fname[100])
  303. {
  304.  int x,y,len;
  305.  char string[255],string1[255],string3[255],string4[255];
  306. /* to get the reverse read of the file name */
  307.  len=strlen(path);
  308.  x=len-1;
  309.  y=0;
  310.  while(x>=0)
  311.   {
  312.    if(path[x]==':' || path[x]=='/') goto got;
  313.    string[y] = path[x];
  314.    x--;
  315.    y++;
  316.   }
  317.  if(y==0) return;     /* Unknown (0)? */
  318.  got:
  319.  string[y]='\0';
  320.  /* reverse read to finish the line to get the path */
  321.  y=0;
  322.  while(x>=0)
  323.   {
  324.    string3[y] = path[x];
  325.    x--;
  326.    y++;
  327.   }
  328.  string3[y]='\0';
  329.  /* flip the path around */
  330.  len=strlen(string3);
  331.  x=len-1;
  332.  y=0;
  333.  while(x>=0)
  334.   {
  335.    string4[y] = string3[x];
  336.    x--;
  337.    y++;
  338.   }
  339.  string4[y]='\0';
  340.  len=strlen(string);
  341.  /* flip the filename around */
  342.  x=len-1;
  343.  y=0;
  344.  while(x>=0)
  345.   {
  346.    string1[y] = string[x];
  347.    x--;
  348.    y++;
  349.   }
  350.  string1[y]='\0';
  351.  strcpy(fname,string1);
  352.  strcpy(path,string4);
  353. }
  354.  
  355.  
  356.  
  357. //*************************
  358. //*****  Close Stuff  *****
  359. //*************************
  360.  
  361. void CloseStuff()
  362. { DOOR_DATA=99; strcpy(DOOR_MSG,'\0'); DOORIO();
  363.  while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
  364.  if(MyPort) DeletePort(MyPort);
  365.  exit(0); }
  366.  
  367. //********************
  368. //*****  DoorIO  *****
  369. //********************
  370.  
  371. int DOORIO()
  372. {
  373.  struct MsgPort *HisPort;
  374.  struct MyMessage message;
  375.  int UPDATE;
  376.  if(EXIT_FLAG) return 0;
  377.  UPDATE=0;
  378.  HisPort = FindPort(st);
  379.  if(HisPort!=NULL)
  380.   {
  381.    message.Msg.mn_Node.ln_Type = NT_MESSAGE;
  382.    message.Msg.mn_Length = sizeof(message);
  383.    message.Msg.mn_ReplyPort = MyPort;
  384.    if(first)CopyMem(&User,&message.User,sizeof(struct User));
  385.    message.car   = 0;
  386.    message.Data  = DOOR_DATA;
  387.    message.Value = DOOR_VALUE;
  388.    message.IntValue = DOOR_VALUE1;
  389.    strcpy(message.text,DOOR_MSG);
  390.    strcpy(message.text1,DOOR_MSG1);
  391.    PutMsg((struct MsgPort *)HisPort,(struct Message *)&message);
  392.    Wait(1 << MyPort->mp_SigBit);
  393.    GetMsg(MyPort);
  394.    DOOR_DATA  = message.Data;
  395.    DOOR_VALUE = message.Value;
  396.    DOOR_VALUE1 = message.IntValue;
  397.    strcpy(DOOR_MSG,message.text);
  398.    strcpy(DOOR_MSG1,message.text1);
  399.    CopyMem(&message.User,&User,sizeof(struct User));
  400.    first=1;
  401.    UPDATE=0;
  402.    if(message.car) EXIT_FLAG=1;
  403.   }
  404.  return 0;
  405. }
  406.  
  407. //************************
  408. //*****  Door Start  *****
  409. //************************
  410.  
  411. DoorStart(char node[])
  412. {
  413.  struct MsgPort *HisPort;
  414.  EXIT_FLAG = 0;
  415.  sprintf(st,"%s:TEMPEST_DOOR",node);
  416.  HisPort = FindPort(st);
  417.  if(HisPort==NULL) return (FALSE);
  418.  sprintf(MyName,"%s:DOOR_PORT",node);
  419.  MyPort = CreatePort(MyName,0L);
  420.  if(MyPort==NULL)
  421.   {
  422.    PutStr("Cant open port");
  423.    return(int)FALSE;
  424.   }
  425.  DOORIO();
  426.  return (int)TRUE;
  427. }
  428.  
  429. //*********************************
  430. //*****  GetStr (Get String)  *****
  431. //*********************************
  432.  
  433. void GetStr(char s[],int opt)
  434. { DOOR_DATA=15; DOOR_VALUE=opt; strcpy(s,'\0'); DOORIO(); strcpy(s,DOOR_MSG); }
  435.  
  436. //*****************
  437. //*****  KEY  *****
  438. //*****************
  439.  
  440. int KEY(void)
  441. { DOOR_DATA=70; DOORIO(); return(DOOR_VALUE); }
  442.  
  443. //*****************************
  444. //*****  PL (Print Line)  *****
  445. //*****************************
  446.  
  447. void pl(char outstring[])
  448. { DOOR_DATA=1; strcpy(DOOR_MSG,outstring); DOORIO(); }
  449.  
  450.  
  451. //*************************
  452. //*****  CTRLC CHECK  *****
  453. //*************************
  454.  
  455. int CTRLC(void)
  456.  {
  457.   DOOR_DATA=73;
  458.   DOORIO();
  459.   return(DOOR_VALUE);
  460.  }
  461.